import serial
import msvcrt
import sys        
import threading

def ReadSerial(ser):
    while 1:
        recbytes = ser.read(1)
        sys.stdout.write(recbytes.decode())
        sys.stdout.flush()

ser = serial.Serial('com2', 9600)
print("connected in COM7 BUNDRATE=9600")
recThread = threading.Thread(target=ReadSerial,args=(ser,))
recThread.setDaemon(True)
recThread.start()
while 1:
    ch = msvcrt.getch()
    ser.write(ch)

